home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / strlib.zip / MEMMOV.C < prev    next >
Text File  |  1993-01-04  |  1KB  |  44 lines

  1.  
  2. /*  File   : memmov.c
  3.     Author : Richard A. O'Keefe.
  4.     Updated: 25 May 1984
  5.     Defines: memmov()
  6.  
  7.     memmov(dst, src, len)
  8.     moves len bytes from src to dst.  The result is dst+len.
  9.     This is to memcpy as str[n]mov is to str[n]cpy, that is, it moves
  10.     exactly the same bytes but returns a pointer to just after the
  11.     the last changed byte.  You can concatenate blocks pa for la,
  12.     pb for lb, pc for lc into area pd by doing
  13.         memmov(memmov(memmov(pd, pa, la), pb, lb), pc, lc);
  14.     Unlike strnmov, memmov does not stop when it hits a NUL byte.
  15.  
  16.     Note: the VAX assembly code version can only handle 0 <= len < 2^16.
  17.     It is presented for your interest and amusement.
  18. */
  19.  
  20. #include "strings.h"
  21.  
  22. #if     VaxAsm
  23.  
  24. char *memmov(dst, src, len)
  25.     char *dst, *src;
  26.     int len;
  27.     {
  28.         asm("movc3 12(ap),*8(ap),*4(ap)");
  29.         return dst+len;
  30.     }
  31.  
  32. #else  ~VaxAsm
  33.  
  34. char *memmov(dst, src, len)
  35.     register char *dst, *src;
  36.     register int len;
  37.     {
  38.         while (--len >= 0) *dst++ = *src++;
  39.         return dst;
  40.     }
  41.  
  42. #endif  VaxAsm
  43.  
  44.